<?php
/**
 * iZAP izap_videos
 *
 * @package Elgg videotizer, by iZAP Web Solutions.
 * @license GNU Public License version 3
 * @Contact iZAP Team "<support@izap.in>"
 * @Founder Tarun Jangra "<tarun@izap.in>"
 * @link http://www.izap.in/
 * @version 3.8b
 */

global $CONFIG;
if(isset ($_POST['izap_send_action'])) {
  if($_POST['izap_send_action'] == 'Let us help you') {
    $string =  'http://www.pluginlotto.com/get_statistics.php?';
    $string .= 'pluign_name=' . $plugin_name . '&';
    foreach($_POST['sendoptions'] as $opt) {
      switch ($opt) {
        case "domain":
          $string .= 'domain=' . urlencode($CONFIG->wwwroot) . '&';
          break;

        case "elgg_version":
          $string .= 'elgg_version=' . urlencode(get_version(TRUE)) . '&';
          break;

        case "admin_email":
          $string .= 'admin_email=' . urlencode(get_loggedin_user()->email) . '&';
          break;

        case "plugin_list":
          $string .= 'plugin_list=' . urlencode(implode(',', get_plugin_list())) . '&';
          break;
      }
    }

    $send_satistics = new curl($string);
    $data = $send_satistics->exec();
    datalist_set('izap_videos_statistics_sent', 'sent');
    system_message(elgg_echo('Thanks for helping us'));
  }else{
    datalist_set('izap_videos_statistics_sent', 'ignored');
    system_message(elgg_echo('No problem, You might change your mind later.'));
  }
  forward($redirect_url);
  exit;
}
set_context('admin');
ob_start();
echo elgg_view_title('Send the following information to iZAP');
?>
<div class="contentWrapper">
  <form action="" method="POST">
    <?php
    echo elgg_view('input/checkboxes', array('internalname' => 'sendoptions',
    'options' => array(
            'Domain' => 'domain',
            'Elgg version' => 'elgg_version',
            'Site admin email' => 'admin_email',
            'Plugin list' => 'plugin_list',
    ),
    'value' => array(
            'Domain' => 'domain',
            'Elgg version' => 'elgg_version',
            'Site admin email' => 'admin_email',
            'Plugin list' => 'plugin_list',
    ),
    ))
    ?>
    <input type="submit" value="Let us help you" name="izap_send_action"/>
    <input type="submit" value="No thanks" name="izap_send_action"/>
  </form>
  <p>
    <em>Notice: We are collecting some details mentioned above. We will not share this information
      for any purpose but the debugging. These stats will really help us to serve better to the
      community. Un-check what you are not comfortable with.</em>
  </p>
</div>
<?php
$content = ob_get_clean();
$body = elgg_view_layout("two_column_left_sidebar", '', $content);
page_draw($title, $body);